"""
异步任务队列模块
提供任务调度、执行和管理功能
"""

from .queue_manager import (
    TaskQueue,
    Task,
    TaskStatus,
    TaskPriority,
    QueueConfig,
    QueueManager,
    queue_manager,
    task,
    run_in_background,
    schedule_task,
    init_default_queues
)

__all__ = [
    # 队列管理
    'TaskQueue',
    'Task',
    'TaskStatus',
    'TaskPriority',
    'QueueConfig',
    'QueueManager',
    'queue_manager',
    
    # 装饰器和便捷函数
    'task',
    'run_in_background',
    'schedule_task',
    'init_default_queues'
]

# 版本信息
__version__ = '1.0.0'
__author__ = 'Offline Language Player Team'


# 初始化
async def init_tasks():
    """初始化任务队列"""
    try:
        await init_default_queues()
        
        logger = get_logger(__name__)
        logger.info("Task queues initialized successfully")
        return True
        
    except Exception as e:
        logger = get_logger(__name__)
        logger.error(f"Failed to initialize task queues: {e}")
        return False


# 清理
async def cleanup_tasks():
    """清理任务队列"""
    try:
        await queue_manager.stop_all()
        
        logger = get_logger(__name__)
        logger.info("Task queues cleaned up successfully")
        return True
        
    except Exception as e:
        logger = get_logger(__name__)
        logger.error(f"Failed to cleanup task queues: {e}")
        return False


# 导入必要的模块
from ..core.logging import get_logger
